﻿using MMOArpgServer.Pool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MMOArpgServer.DAL
{
    public class AccountDBData : AbsCacheData
    {
        private int _AccountID = -1;
        private string _Account;
        private string _Password;
        private bool _IsOffline=true;
        private int[] _CharactersID;
        public string Account
        {
            get
            {
                return _Account;
            }

            set
            {
                _Account = value;
            }
        }

        public string Password
        {
            get
            {
                return _Password;
            }

            set
            {
                _Password = value;
            }
        }

        public bool IsOffline
        {
            get
            {
                return _IsOffline;
            }

            set
            {
                _IsOffline = value;
            }
        }

        public int AccountID
        {
            get
            {
                return _AccountID;
            }

            set
            {
                _AccountID = value;
            }
        }

        public int[] CharactersID
        {
            get
            {
                return _CharactersID;
            }

            set
            {
                _CharactersID = value;
            }
        }

        public AccountDBData() { }
        public AccountDBData(string account, string password)
        {
            _Account = account;
            _Password = password;
            _IsOffline = false;
        }
        public override void Release()
        {
            _IsOffline = true;
            base.Release();
        }
        public override void CreateData()
        {

        }

        protected override void OperateDB()
        {
            //DBConnect db = DBConnectPool.GetInstance().GetConnect();
            //db.ConnectDB();
            //string charactersID = LitJson.JsonMapper.ToJson(CharactersID);
            //MySqlParameter[] parameters = new MySqlParameter[] {
            //  new MySqlParameter("Password",Password),
            //  new MySqlParameter("IsOffline",IsOffline.ToString()),
            //  new MySqlParameter("CharactersID",charactersID)
            //};
            //db.Update("account", parameters, new MySqlParameter("AccountID", AccountID));
            //db.CloseConnect();
        }
    }
}
